<template>
  <div class="carousel">
    <el-carousel
      height="100%"
      direction="vertical"
      :autoplay="false"
      @change="change"
    >
      <el-carousel-item v-for="item in total" :key="item.name">
        <div
          v-for="item2 in 3"
          :key="item2"
          class="block"
          :class="[item.name === activeIndex ? 'isActive' : '', `item${item2}`]"
        >
          {{ item.name }}
        </div>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>
<script>
export default {
  data() {
    return {
      total: [{ name: 0 }, { name: 1 }, { name: 2 }],
      activeIndex: -1,
      show: false
    }
  },
  mounted() {
    setTimeout(() => {
      this.activeIndex = 0
    }, 0)
  },
  methods: {
    change(v) {
      console.log(v)
      this.activeIndex = v
    }
  }
}
</script>
<style lang="less">
.el-carousel {
  height: inherit;
}

.carousel {
  height: calc(100vh - 200px);
}
.el-carousel__item {
  display: flex;
  justify-content: center;
  align-items: center;
}
.block {
  width: 100px;
  height: 100px;
  background: #000;
  transform: translateY(50px);
  transition: all 1s ease-in-out;
  margin-right: 50px;
  &:hover {
    transform: translateY(-10px);
  }
}
.isActive {
  transform: translateY(0px);
}
.item2 {
  transition: all 1s 1s ease-in-out;
}
.item3 {
  transition: all 1s 2s ease-in-out;
}
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>
